Conversation
When Maven's surefire plugin runs unit tests, the URLClassLoader does actually not list the URLs corresponding to the dependencies. Instead, surefire tries to be clever and hides those dependencies inside a single, empty .jar file's manifest's Class-Path: entry. We are not dumb, so surefire loses: we get the URLs anyway. Hah! Take this, surefire! *shakes-fist* Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
... even when run via surefire... To that end, we piggy-back on the already existing test for bare .java "scripts": as scijava-common is a dependency of scripting-java, let's just use one of scijava-common's utility classes in the bare .java "script". That way, the test will only pass when scijava-common's class is found on the compiler class path. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
If we ever limit which class loader we use as parent or to discover the available dependencies by using the class loader that happened to load MiniMaven, we will be in for a *lot* of trouble in the future, e.g. with ImageJ 1.x' PluginClassLoader. So let's not do that. Let's use the current thread's context class loader, like everywhere else we need a class loader. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Contributor
Author
|
I re-tested, all is fine. I also added a couple of commits that do not technically have anything to do with surefire, but they fix issues discovered while working on this branch. @ctrueden could you have a quick look again and merge if you don't see problems with the PR? |
Member
|
Looks good! |
ctrueden
added a commit
that referenced
this pull request
Jun 19, 2014
Allow running inside Maven unit tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Maven's surefire plugin runs unit tests, the URLClassLoader does
actually not list the URLs corresponding to the dependencies. Instead,
surefire tries to be clever and hides those dependencies inside a
single, empty .jar file's manifest's Class-Path: entry.
We are not dumb, so surefire loses: we get the URLs anyway. Hah! Take
this, surefire! shakes-fist
This came up while working on a regression test for http://fiji.sc/bugzilla/show_bug.cgi?id=787.
Signed-off-by: Johannes Schindelin johannes.schindelin@gmx.de